import zlib
import bz2

s = open('package.pack','rb').read()
l = []
while True:
    if s.startswith('BZh'):
        s = bz2.decompress(s)
        l.append('B')
    elif s.startswith('x\x9c'):
        s = zlib.decompress(s)
        l.append('x')
    else:
        l.append('\n')
        # try reverse
        s = s[::-1]
        if s.startswith('BZh'):
            s = bz2.decompress(s)
            l.append('B')
        elif s.startswith('x\x9c'):
            s = zlib.decompress(s)
            l.append('x')
        else:
            break

open('package','wb').write(s)
open('log.log','wb').write(''.join(l))
